package etxt2db.features;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import java.util.regex.Pattern;



public class RegexFeatureClassifier extends CharacterFeatureClassifier implements Serializable {
	/**
	 * 
	 */
	private static final long serialVersionUID = 1310008566788694004L;
	String regex;
	
	public RegexFeatureClassifier(String regex){
		this.regex = regex;
	}

	public List<String> emit(String text) {
		boolean matches = Pattern.matches(regex, text);
		List<String> result = new ArrayList<String>();
		if(matches){
			result.add("matchRegex_" + regex + "=" + matches);
		}
		return result;
	}

}
